BX.namespace("BX.Helper");BX.Helper={frameOpenUrl:"",frameNode:null,openBtn:null,popupLoader:null,langId:null,ajaxUrl:"",currentStepId:"",notifyBlock:null,notifyNum:"",notifyText:"",notifyId:0,notifyButton:"",isAdmin:"N",version:2,init:function(t){this.frameOpenUrl=t.frameOpenUrl||"";this.langId=t.langId||"";this.openBtn=t.helpBtn;this.notifyBlock=t.notifyBlock;this.ajaxUrl=t.ajaxUrl||"";this.currentStepId=t.currentStepId||"";this.notifyData=t.notifyData||null;this.runtimeUrl=t.runtimeUrl||null;this.notifyUrl=t.notifyUrl||"";this.helpUrl=t.helpUrl||"";this.notifyNum=t.notifyNum||"";this.isAdmin=t.isAdmin&&t.isAdmin==="Y"?"Y":"N";if(this.openBtn){this.openBtn.addEventListener("click",(function(){if(BX.Helper.isOpen()){BX.Helper.close()}else{BX.Helper.show()}BX.Helper.setBlueHeroView()}))}BX.bind(window,"message",BX.proxy((function(t){var e=t.origin||"";var i=new URL(this.frameOpenUrl).origin;if(e!==i){return}if(!t.data||typeof t.data!=="object"){return}if(t.data.action==="CloseHelper"){this.close()}if(t.data.action==="SetCounter"){BX.Helper.setNotification(t.data.num);BX.Helper.showNotification(t.data.num)}if(t.data.action==="GetVersion"){this.frameNode.contentWindow.postMessage({action:"throwVersion",version:this.version},"*")}if(t.data.action==="OpenChat"){BXIM.openMessenger(t.data.user_id)}if(t.data.action==="getMenuStructure"){if(BX.getClass("BX.Intranet.LeftMenu")){if(typeof BX.Intranet.LeftMenu.getStructureForHelper==="function"){var n=BX.Intranet.LeftMenu.getStructureForHelper();this.frameNode.contentWindow.postMessage({action:"throwMenu",menu:n},"*")}}}if(t.data.action==="getNewArticleCount"){var o={action:"throwNewArticleCount",articleCount:this.notifyNum};if(this.notifyData){o.lastTimestampCheckNewArticle=this.notifyData.counter_update_date}this.frameNode.contentWindow.postMessage(o,"*")}}),this));if(t.needCheckNotify==="Y"){this.checkNotification()}if(this.notifyNum>0){BX.Helper.showNotification(this.notifyNum)}},show:function(t,e){if(this.isOpen()){return}if(!BX.Type.isPlainObject(e)){e={}}const i=this.frameOpenUrl+(this.frameOpenUrl.indexOf("?")<0?"?":"&")+(BX.type.isNotEmptyString(t)?t:"");let n=new URL(i);n.searchParams.delete("url");n.searchParams.append("url",window.location.href);n=n.toString();if(this.getFrame().src!==n){this.getFrame().src=n}BX.SidePanel.Instance.open(this.getSliderId(),{contentCallback:function(t){var e=new BX.Promise;e.fulfill(this.getContent());return e}.bind(this),width:860,cacheable:false,zIndex:e.zIndex||null,events:{onCloseComplete:function(){BX.Helper.close()},onLoad:function(){BX.Helper.showFrame()},onClose:function(){BX.Helper.frameNode.contentWindow.postMessage({action:"onCloseWidget"},"*")}}});if(this.isAdmin==="N"&&this.openBtn){BX.addClass(this.openBtn,"help-block-active")}},close:function(){var t=this.getSlider();if(t){t.close()}if(this.isAdmin==="N"){if(this.openBtn){BX.removeClass(this.openBtn,"help-block-active")}this.getFrame().classList.remove("helper-panel-iframe-show")}},getContent:function(){if(this.content){return this.content}this.content=BX.create("div",{attrs:{className:"helper-container"},children:[this.getLoader(),this.getFrame()]});return this.content},getFrame:function(){if(this.frameNode){return this.frameNode}this.frameNode=BX.create("iframe",{attrs:{className:"helper-panel-iframe",src:"about:blank",allowfullscreen:"on"}});return this.frameNode},showFrame:function(){setTimeout(function(){this.getFrame().classList.add("helper-panel-iframe-show")}.bind(this),600)},getLoader:function(){if(this.popupLoader){return this.popupLoader}this.popupLoader=BX.create("div",{attrs:{className:"bx-help-popup-loader"},children:[BX.create("div",{attrs:{className:"bx-help-popup-loader-text"},text:BX.message("MAIN_HELPER_LOADER")})]});return this.popupLoader},getSliderId:function(){return"main:helper"},getSlider:function(){return BX.SidePanel.Instance.getSlider(this.getSliderId())},isOpen:function(){return this.getSlider()&&this.getSlider().isOpen()},setBlueHeroView:function(){if(!this.currentStepId)return;BX.ajax.post(this.ajaxUrl,{sessid:BX.bitrix_sessid(),action:"setView",currentStepId:this.currentStepId},(function(){}))},showNotification:function(t){if(!this.notifyBlock){return}if(!isNaN(parseFloat(t))&&isFinite(t)&&t>0){var e='<div class="help-cl-count"><span class="help-cl-count-digit">'+(t>99?"99+":t)+"</span></div>"}else{e=""}this.notifyBlock.innerHTML=e;this.notifyNum=t},showFlyingHero:function(url){if(!url)return;BX.ajax({method:"GET",dataType:"html",url:this.helpUrl+url,data:{},onsuccess:BX.proxy((function(res){if(res){BX.load([this.runtimeUrl],(function(){eval(res)}))}}),this)})},setNotification:function(t,e){BX.ajax({method:"POST",dataType:"json",url:this.ajaxUrl,data:{sessid:BX.bitrix_sessid(),action:"setNotify",num:t,time:e},onsuccess:BX.proxy((function(t){}),this)})},checkNotification:function(){BX.ajax({method:"POST",dataType:"json",url:this.notifyUrl,data:this.notifyData,onsuccess:BX.proxy((function(t){if(!isNaN(t.num)){this.setNotification(t.num);this.showNotification(t.num);if(t.id){this.notifyId=t.id;this.notifyText=t.body;this.notifyButton=t.button}if(t.url)this.showFlyingHero(t.url)}else{this.setNotification("","hour")}}),this),onfailure:BX.proxy((function(){this.setNotification("","hour")}),this)})},showAnimatedHero:function(){if(!BX.browser.IsIE8()){BX.load(["/bitrix/js/main/helper/runtime.js","/bitrix/js/main/helper/hero_object.js"],(function(){var t=BX.create("div",{attrs:{className:"bx-help-start",id:"bx-help-start"}});if(BX.admin&&BX.admin.panel){t.style.top=BX.admin.panel.DIV.offsetHeight+50+"px"}document.body.appendChild(t);var e=new swiffy.Stage(t,swiffyobject,{});e.setBackground(null);setTimeout((function(){e.start()}),300);setTimeout((function(){t.style.display="none"}),7300)}))}}};
//# sourceMappingURL=helper.map.js